package com.itheima.tcp.Demo2;

import java.io.*;
import java.net.ServerSocket;
import java.net.Socket;
import java.util.UUID;

public class Server {
    public static void main(String[] args) throws IOException {
        ServerSocket socket = new ServerSocket(10000);
        while (true) {
            Socket accept = socket.accept();
            BufferedInputStream bis = new BufferedInputStream(accept.getInputStream());
            BufferedOutputStream bos = new BufferedOutputStream(new FileOutputStream("test_网络编程入门\\"+ UUID.randomUUID().toString() +".jpg"));
            int b;
            while((b = bis.read())!=-1){
                bos.write(b);
            }
            BufferedWriter bw = new BufferedWriter(new OutputStreamWriter(accept.getOutputStream()));
            bw.write("上传成功");
            bw.newLine();
            bw.flush();

            bos.close();
            accept.close();
        }
        //socket.close();
    }
}
